package org.iori.luodan.servlet;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.iori.json.JSONHelper;
import org.iori.luodan.base.BaseLogicFactory;
import org.iori.luodan.logic.GoodsLogic;
import org.iori.luodan.base.BaseServlet;
import org.iori.luodan.entity.GoodsEntity;

public class GetGoodsServlet extends BaseServlet {
	/**
	 * 
	 */
	private static final long serialVersionUID = 7899972223684720090L;
	
	private static GoodsLogic goodsLogic = BaseLogicFactory.getGoodsLogic();
    
	@Override
	protected String doExcute(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		// TODO Auto-generated method stub
		// currentPageを取得する
		Object obj_goods_id = request.getParameter("goods_id");
		int goods_id = 1;
		if (null != obj_goods_id) {
			goods_id = Integer.parseInt(obj_goods_id.toString());
		}

		GoodsEntity content = goodsLogic.getGoods(goods_id);
		
		response.setCharacterEncoding("utf-8");
		response.setContentType("application/json;charset=utf-8");
		JSONHelper.writeObject(response, content);
		return null;
	}

}
